<?php
require('../../../global.php');
//进入页面后先判断是否有访问权限
checkAdminAuthorizeAndJump('expert.finish');

if(isset($_GET['id'])){
    $order = $db->get('tb_order', '*', array('tbid' => $_GET['id']));
    $expert = $db->get('tb_class', '*', array('tbid' => $order['class_id']));
    $reserveInfo = $db->get('tb_expert_reserve', '*', array('order_id' => $_GET['id']));
    $member = $db->get('tb_member', '*', array('tbid' => $order['member_id']));

}
?>
<!DOCTYPE html>
<html>
<head>
    <?php require('admin/_head.php'); ?>
    <title>会员管理 - <?php echo getconfig('title'); ?>管理后台</title>

    <link href="<?php echo SITEROOTURL; ?>/admin/js/plugins/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css" rel="stylesheet">
</head>
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h3>
                    <button type="button" class="btn btn-white btn-sm closelayer">返回</button>
                    查看预约信息
                </h3>
            </div>
            <div class="ibox-content">
                <div class="row row-lg">
                    <div class="col-sm-12">
                        <form class="form-horizontal" id="editForm" action="ajax.php">
                            <input type="hidden" name="ac" value="editFollow">
                            <input type="hidden" name="id" value="<?php echo $reserveInfo['tbid']; ?>">

                            <div class="form-group">
                                <label class="col-sm-2 control-label">订单号</label>
                                <div class="col-sm-10">
                                    <p class="form-control-static"><?php echo $order['order_number']; ?></p>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">预约专家</label>
                                <div class="col-sm-10">
                                    <p class="form-control-static"><?php echo $expert['name']; ?></p>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">用户名</label>
                                <div class="col-sm-10">
                                    <p class="form-control-static"><?php echo $member['nickname']; ?></p>
                                </div>
                            </div>

                            
                            <div class="form-group">
                                <label class="col-sm-2 control-label">手机号</label>
                                <div class="col-sm-10">
                                      <p class="form-control-static"><?php echo $member['mobile']; ?></p>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">客户备注</label>
                                <div class="col-sm-10">
                                     <p class="form-control-static"><?php echo $reserveInfo['remark']; ?></p>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">预约次数</label>
                                <div class="col-sm-10">
                                     <p class="form-control-static"><?php echo $order['reserve_number']; ?></p>
                                    
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">用户预约时间</label>
                                <div class="col-sm-10">
                                     <p class="form-control-static">
                                     <?php 
                                        $reserveWhere['AND']['order_id'] = $_GET['id'];
                                        $reserveWhere['ORDER']['tbid'] = 'DESC';
                                        $reserveResult = $db->get('tb_expert_reserve', '*', $reserveWhere);
                                        $reserve_time = $reserveResult['reserve_time'];
                                        if ($reserve_time == '0000-00-00 00:00:00' || empty($reserve_time)) {
                                            $reserve_time = '';
                                        }
                                     echo $reserve_time; ?></p>
                                    
                                </div>
                            </div>
                             <div class="form-group">
                                <label class="col-sm-2 control-label">全款金额</label>
                                <div class="col-sm-10">
                                     <p class="form-control-static"><?php echo $order['full_payment']/100; ?></p>
                                    
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">付款时间</label>
                                <div class="col-sm-10">
                                     <p class="form-control-static">
                                     <?php
                                        $paytime = $db->get('tb_order_log', 'dt', array('order_no' => $order['order_number']));
            if ($paytime == '0000-00-00 00:00:00' || empty($paytime)){
                    $paytime = '';
                }

                                      echo $paytime; ?></p>

                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">创建时间</label>
                                <div class="col-sm-10">
                                     <p class="form-control-static"><?php echo $order['createtime']; ?></p>
                                    
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">预约确认时间</label>
                                <div class="col-sm-10">
                                    <input type="text" name="confirm_time" id="confirm_time" placeholder="请输入确认时间" class="form-control" value="<?php echo (($reserveInfo['confirm_time'] != '0000-00-00 00:00:00') ?$reserveInfo['confirm_time'] :''); ?>" >
                                    <span class="help-block m-b-none"></span>
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <label class="col-sm-2 control-label">情况说明</label>
                                <div class="col-sm-10">
                                     <textarea name="situation" id="situation" placeholder="请输入情况说明" class="form-control" ><?php echo $reserveInfo['situation']; ?></textarea>
                                    <span class="help-block m-b-none"></span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">是否面询</label>
                                <div class="col-sm-10">
                                     <select class="form-control" name="is_test" >
                                        <option value='1' <?php echo 1==$reserveInfo['is_test']?'selected':''; ?>> 是 </option>
                                        <option value='0' <?php echo 0==$reserveInfo['is_test']?'selected':''; ?>> 否 </option>
                                    </select>
                                    <span class="help-block m-b-none"></span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">面询时间</label>
                                <div class="col-sm-10">
                                    <input type="text" name="test_time" id="test_time" placeholder="请输入面询时间" class="form-control" value="<?php echo (($reserveInfo['test_time'] != '0000-00-00 00:00:00') ?$reserveInfo['test_time'] :''); ?>" >
                                    <span class="help-block m-b-none"></span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">面询结果</label>
                                <div class="col-sm-10">
                                     <textarea name="reserve_result" id="reserve_result" placeholder="请输入面询结果" class="form-control" ><?php echo $reserveInfo['reserve_result']; ?></textarea>
                                    <span class="help-block m-b-none"></span>
                                </div>
                            </div>
                           <div class="form-group">
                                <label class="col-sm-2 control-label">用户评价</label>
                                <div class="col-sm-10">
                                     <textarea name="evaluation" id="evaluation" placeholder="请输入用户评价" class="form-control" ><?php echo $reserveInfo['evaluation']; ?></textarea>
                                    <span class="help-block m-b-none"></span>
                                </div>
                            </div>
                             <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-2">
                                    <button class="btn btn-primary btn-lg" type="submit" id="btn-submit">保存内容</button>
                                    <button class="btn btn-white btn-lg closelayer" type="button">取消</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <?php require('admin/_js.php'); ?>
    <script src="<?php echo SITEROOTURL; ?>/admin/js/content.js?v=1.0.0"></script>
    <script src="<?php echo SITEROOTURL; ?>/admin/js/plugins/validform/Validform_min.js"></script>
    <script src="<?php echo SITEROOTURL; ?>/admin/js/plugins/validform/Validform_Datatype.js"></script>
    <script src="<?php echo SITEROOTURL; ?>/admin/js/plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
    <script src="<?php echo SITEROOTURL; ?>/admin/js/plugins/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
    <script src="<?php echo SITEROOTURL; ?>/admin/js/jbase64.js"></script>
    <script>
    $(function(){
        var closeLayer = function(){
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            parent.closeLayer(index);
        }
        $('.closelayer').click(function(event){
            closeLayer();
        });
        $('#confirm_time').datetimepicker({
            language : 'zh-CN',
            format : 'yyyy-mm-dd hh:ii',
            weekStart : 1,
            startView : 2,
            todayHighlight : true,
            autoclose : true
        }).on('changeDate', function(){
            form.check(false, $(this));
        });
        $('#test_time').datetimepicker({
            language : 'zh-CN',
            format : 'yyyy-mm-dd hh:ii',
            weekStart : 1,
            startView : 2,
            todayHighlight : true,
            autoclose : true
        }).on('changeDate', function(){
            form.check(false, $(this));
        });
        var form = $('#editForm').Validform({
            btnSubmit: '#btn-submit',
            postonce: false,
            showAllError: true,
            //msg：提示信息;
            //o:{obj:*,type:*,curform:*}, obj指向的是当前验证的表单元素（或表单对象），type指示提示的状态，值为1、2、3、4， 1：正在检测/提交数据，2：通过验证，3：验证失败，4：提示ignore状态, curform为当前form对象;
            //cssctl:内置的提示信息样式控制函数，该函数需传入两个参数：显示提示信息的对象 和 当前提示的状态（既形参o中的type）;
            tiptype: function(msg, o){
                if(!o.obj.is('form')){//验证表单元素时o.obj为该表单元素，全部验证通过提交表单时o.obj为该表单对象;
                    var B = o.obj.parents('.form-group');
                    var T = B.find('.help-block');
                    if(o.type == 2){
                        B.removeClass('has-error').addClass('has-success');
                        T.html('');
                    }else{
                        B.removeClass('has-success').addClass('has-error');
                        T.html("<i class='fa fa-times-circle'></i> " + msg);
                    }
                }
            },
            ajaxPost: true,
            callback: function(data){
                if(data.status == 'y'){
                    parent.swal('操作成功', '', 'success');
                    closeLayer();
                }else{
                    swal('操作失败', '', 'error');
                }
            }
        });
    });

    </script>
</body>
</html>
